result = [0] * 4


def isOK (n, pos):
    for i in range(n):
        if result[i] == pos or abs(i-n) == abs(result[i] - pos):
            return False
    return True


def main():
    for p0 in range(4):
        if isOK(0, p0):
            result[0] = p0
            for p1 in range(4):
                if isOK(1, p1):
                    result[1] = p1
                    for p2 in range(4):
                        if isOK(2, p2):
                            result[2] = p2
                            for p3 in range(4):
                                if isOK(3, p3):
                                    result[3] = p3
                                    for x in result:
                                        print(x, end=" ")
                                    print("")


main()
